﻿// Decompiled with JetBrains decompiler
// Type: TaleWorlds.CampaignSystem.Conversation.Persuasion.PersuasionAttempt
// Assembly: TaleWorlds.CampaignSystem, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E85F8C15-4DF6-4E9C-A58A-29177E40D07A
// Assembly location: D:\steam\steamapps\common\Mount & Blade II Bannerlord\bin\Win64_Shipping_Client\TaleWorlds.CampaignSystem.dll

using System.Collections.Generic;
using TaleWorlds.SaveSystem;

#nullable disable
namespace TaleWorlds.CampaignSystem.Conversation.Persuasion
{
  public class PersuasionAttempt
  {
    [SaveableField(2)]
    public readonly int ReservationType;
    [SaveableField(3)]
    public readonly Hero PersuadedHero;
    [SaveableField(4)]
    public readonly CampaignTime GameTime;
    [SaveableField(5)]
    public readonly PersuasionOptionArgs Args;
    [SaveableField(6)]
    public readonly PersuasionOptionResult Result;

    internal static void AutoGeneratedStaticCollectObjectsPersuasionAttempt(
      object o,
      List<object> collectedObjects)
    {
      ((PersuasionAttempt) o).AutoGeneratedInstanceCollectObjects(collectedObjects);
    }

    protected virtual void AutoGeneratedInstanceCollectObjects(List<object> collectedObjects)
    {
      collectedObjects.Add((object) this.PersuadedHero);
      CampaignTime.AutoGeneratedStaticCollectObjectsCampaignTime((object) this.GameTime, collectedObjects);
      collectedObjects.Add((object) this.Args);
    }

    internal static object AutoGeneratedGetMemberValueReservationType(object o)
    {
      return (object) ((PersuasionAttempt) o).ReservationType;
    }

    internal static object AutoGeneratedGetMemberValuePersuadedHero(object o)
    {
      return (object) ((PersuasionAttempt) o).PersuadedHero;
    }

    internal static object AutoGeneratedGetMemberValueGameTime(object o)
    {
      return (object) ((PersuasionAttempt) o).GameTime;
    }

    internal static object AutoGeneratedGetMemberValueArgs(object o)
    {
      return (object) ((PersuasionAttempt) o).Args;
    }

    internal static object AutoGeneratedGetMemberValueResult(object o)
    {
      return (object) ((PersuasionAttempt) o).Result;
    }

    public PersuasionAttempt(
      Hero persuadedHero,
      CampaignTime gameTime,
      PersuasionOptionArgs args,
      PersuasionOptionResult result,
      int reservationType)
    {
      this.PersuadedHero = persuadedHero;
      this.GameTime = gameTime;
      this.Args = args;
      this.Result = result;
      this.ReservationType = reservationType;
    }

    public bool IsSuccesful()
    {
      return this.Result == PersuasionOptionResult.Success || this.Result == PersuasionOptionResult.CriticalSuccess;
    }

    public bool Matches(Hero targetHero, int reservationType)
    {
      return this.PersuadedHero == targetHero && this.ReservationType == reservationType;
    }
  }
}
